import java.util.Random;
import java.util.Scanner;

/**
 * Created by dllo on 18/3/30.
 */
public class Question03 {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        Random random = new Random();
        int money = 5000;//初始赌资
        while (money > 0) {
            System.out.println("请猜大小,猜大输入0,猜小输入1,猜点数请输入3-18之间任意点数:");
            int numberSize = scanner.nextInt();//猜大小或输入点数
            while (numberSize > 18 || numberSize == 2 || numberSize < 0) {//点数输错,重新输入
                System.out.println("请输入正确点数:");
                numberSize = scanner.nextInt();
                continue;
            }
            System.out.println("请输入金额:");
            int gambleMoney = scanner.nextInt();//输入押金
            while (gambleMoney > money) {//超过拥有最大金额,重新输入
                System.out.println("请输入正确金额:");
                gambleMoney = scanner.nextInt();
                continue;
            }
            int a = random.nextInt(6) + 1;
            int b = random.nextInt(6) + 1;
            int c = random.nextInt(6) + 1;
            int sum = a + b + c;
            if ((numberSize == 0 || numberSize == 1)) {//猜大小模式:0猜大,1猜小
                switch (numberSize) {
                    case 0://猜大
                        System.out.println("你已经猜大");
                        if (sum >= 11 && sum <= 18) {
                            System.out.println("你赢了");
                            money = money + gambleMoney;
                        } else {
                            System.out.println("你输了");
                            money = money - gambleMoney;
                        }
                        break;
                    case 1://猜小
                        System.out.println("你已经猜小");
                        if (sum >= 3 && sum <= 10) {
                            System.out.println("你赢了");
                            money = money + gambleMoney;
                        } else {
                            System.out.println("你输了");
                            money = money - gambleMoney;
                        }
                        break;
                }
            } else if (numberSize >= 3 && numberSize <= 18) {//猜点数模式
                if (sum == numberSize) {
                    System.out.println("你赢了");
                    money = money + 16 * gambleMoney;
                } else {
                    System.out.println("你输了");
                    money = money - gambleMoney;
                }
            }
            System.out.println("三个骰子点数分别为:" + a + "," + b + "," + c);
            System.out.println("总点数为:" + sum);
            System.out.println("剩余钱数为:" + money);
        }
        System.out.println("钱已输光");

        // 1. 用户有5000元
        // 2. 用户输入大小(0-大,1-小)
        // 3. 生成三个1-6 的随机数作为骰子
        // 4. 根据点数和 判断大小
        // 5. 根据点数大小,和用户输入的大小进行比较,
        //       如果一致,用户金额+50
        // 如果不一致, 用户金额 -50
        // 6. 用户没钱了 让他退出
        // 7. 循环 2-6
        /* int money = 5000;

        while (true) {
            int guess = scanner.nextInt();

            int dice = random.nextInt(6) + 1;
            int dice2 = random.nextInt(6) + 1;
            int dice3 = random.nextInt(6) + 1;

            int sum = dice + dice2 + dice3;
            /*if (sum >= 11){

            }else{
                if (guess < 11){

                }else{

                }
             }*/
            /*  int result = sum > 10 ? 0 : 1;
            System.out.println("三个骰子点数分别为:" + dice + "," + dice2 + "," + dice3);
            if (result == guess) {
                money = money + 50;
            } else {
                money = money - 50;
            }
            System.out.println("还有" + money + "钱");
            if (money <= 0) {

            }

                System.out.println("退出了");
                break;

        }*/
    }
}
